<!-- 10分钟 -->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./OL_SDK/include-openlayers-local.js"></script>
    <script src="./libs/gaode.js"></script>
    <script src="./utils/createDraw.js"></script>
    <script src="./utils/getFeatureGeom.js"></script>
    <script src="./utils/Query.js"></script>
</head>

<body>
    <div id="map">
    </div>
    <script>
        var docLayer = new Zondy.Map.Doc("", "myTestMap", {

        })
        var map = new ol.Map({
            target: "map",
            layers: [gaode, docLayer],
            view: new ol.View({
                projection: 'EPSG:4326',
                center: [114.30, 30.50],
                zoom: 4
            })
        })
        var source = new ol.source.Vector({

        })
        var layer = new ol.layer.Vector({
            source
        })
        map.addLayer(layer)
        /* 1、点画笔获取坐标 */
        let draw = createDraw({
            type: "Point",
            source
        })
        map.addInteraction(draw);
        draw.on("drawend", evt => {
            source.clear()
            /* geometry */
            // console.log(position,'position') // [114,30]
            /* 2、调用Query方法,进行查询 */
            let position = getFeatureGeom(evt.feature)
            let service = {
                name: "myTestMap",
                layerId: 0
            }
            Query.queryByPoint({
                position,
                service,
                success(features) {
                    console.log(features, 'features')
                    // source.clear()
                }
            })
        })

    </script>
</body>

</html>